//
//  BLRECKit.h
//  vrmuApp
//
//  Created by Benz.L on 24/07/2018.
//  Copyright © 2018 广东瑞亚传媒发展有限公司. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>

@class BLRECKit;

typedef enum {
    RECStateNone = 0,
    RECStateRecording,
    BLRECStateFailure,
    BLRECStateFinished,
	BLRECStateNotAuthorized = -1
}RECState;

@protocol BLRECKitDelegate<NSObject>
@optional
- (void)recKit:(BLRECKit *)kit recStateChanged:(RECState)state;
- (void)recKit:(BLRECKit *)kit didFinishREC:(NSURL *)videoURL;
- (void)recKit:(BLRECKit *)kit didFailure:(NSError *)error;
@end

@interface BLRECKit : NSObject
@property(nonatomic, assign, readonly) RECState state;
@property(nonatomic, weak) id<BLRECKitDelegate> delegate;
@property(nonatomic, assign) BOOL micEnable; // 是否开启麦克风,默认为NO(开麦的话背景音乐会变得很小)

+ (void)requireAuthorizeIfNeeded:(void(^)(BOOL granted))complete;
+ (BOOL)canREC;
- (void)startREC;
- (void)stopREC;

@end


@interface BLRECKit (Frame)

/**
 @brief 截取视频指定位置的帧图像
 @param videoURL 视频文件路径
 @param time	 要获取图像的位置，单位为秒
 */
+ (UIImage *)frameFromVideo:(NSURL *)videoURL atTime:(NSTimeInterval)time;

/**
 @brief 获取视频总时长,单位秒
 @param videoURL 本地视频文件路径
 */
+ (NSTimeInterval)videoDuration:(NSURL *)videoURL;

@end
